package view.lager;

import model.Vare;
import utility.PriceFormater;


public class VarePanel extends javax.swing.JDialog {

    private final Vare vare;

    public VarePanel(java.awt.Frame parent, boolean modal, Vare vare) {
        super(parent, modal);
        initComponents();
        this.vare = vare;
        setSize(700, 475);
        setfields(vare);
        setLocationRelativeTo(null);
    }

    /**
     * Sætter alle tekstfelter med Lager objektets data
     * @param lager Lager
     */
    private void setfields(Vare vare) {
        jTextField_Varenavn.setText(vare.getVarenavn());
        jTextField_Varenr.setText(vare.getVarenummer() + "");
        jTextField_Varegrp.setText(vare.getVaregruppe().getNavn());
        jTextField_UdsalgsprisDKK.setText(PriceFormater.formaterPrisTilString(vare.getUdsalgsprisDKK()));
        jTextField_UdsalgsprisEUR.setText(PriceFormater.formaterPrisTilString(vare.getUdsalgsprisEURO()));
        jTextField_Rabat.setText(vare.getRabat() + "%");
        jTextField_Leverandør.setText(vare.getLeverandør().getFirmaNavn());
        jTextField_Adresse.setText(vare.getLeverandør().getAdresse());
        jTextField_Kontaktperson.setText(vare.getLeverandør().getKontaktPerson());
        jTextField_Tlf.setText(vare.getLeverandør().getTlfNr());
        jTextField_Indkøbspris.setText(PriceFormater.formaterPrisTilString(vare.getIndkøbspris()));
        jTextField_PriDKKmedRabat.setText(PriceFormater.formaterPrisTilString(vare.getUdsalgsprisDKKMedRabat()));
        jTextField_prisEUROmedRabat.setText(PriceFormater.formaterPrisTilString(vare.getUdsalgsprisEUROMedRabat()));
        jTextField_Lager.setText(vare.getAntal()+"");

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jTextField_Adresse = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTextField_Kontaktperson = new javax.swing.JTextField();
        jTextField_Leverandør = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField_Tlf = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jTextField_Varenavn = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jTextField_Varenr = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextField_Varegrp = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField_Lager = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jTextField_UdsalgsprisEUR = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextField_Rabat = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextField_Indkøbspris = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextField_UdsalgsprisDKK = new javax.swing.JTextField();
        jTextField_prisEUROmedRabat = new javax.swing.JTextField();
        jTextField_PriDKKmedRabat = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();

        setTitle("Info om varen");
        getContentPane().setLayout(null);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setText("Vare");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(20, 0, 120, 30);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel13.setText("Leverandør");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(400, 0, 130, 30);

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel14.setText("Pris");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(20, 254, 100, 30);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        jPanel1.setOpaque(false);
        jPanel1.setLayout(null);

        jTextField_Adresse.setEditable(false);
        jTextField_Adresse.setPreferredSize(new java.awt.Dimension(70, 25));
        jPanel1.add(jTextField_Adresse);
        jTextField_Adresse.setBounds(20, 180, 240, 40);

        jLabel3.setText("Adresse");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(20, 150, 110, 30);

        jLabel11.setText("Kontaktperson");
        jLabel11.setPreferredSize(new java.awt.Dimension(60, 20));
        jPanel1.add(jLabel11);
        jLabel11.setBounds(20, 80, 160, 30);

        jTextField_Kontaktperson.setEditable(false);
        jTextField_Kontaktperson.setPreferredSize(new java.awt.Dimension(70, 25));
        jPanel1.add(jTextField_Kontaktperson);
        jTextField_Kontaktperson.setBounds(20, 110, 240, 40);

        jTextField_Leverandør.setEditable(false);
        jTextField_Leverandør.setPreferredSize(new java.awt.Dimension(70, 25));
        jPanel1.add(jTextField_Leverandør);
        jTextField_Leverandør.setBounds(20, 40, 240, 40);

        jLabel2.setText("Firmanavn");
        jLabel2.setPreferredSize(new java.awt.Dimension(60, 20));
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 10, 110, 30);

        jTextField_Tlf.setEditable(false);
        jTextField_Tlf.setPreferredSize(new java.awt.Dimension(70, 25));
        jPanel1.add(jTextField_Tlf);
        jTextField_Tlf.setBounds(20, 260, 240, 40);

        jLabel17.setText("Telefon");
        jPanel1.add(jLabel17);
        jLabel17.setBounds(20, 230, 130, 30);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(400, 30, 280, 400);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        jPanel2.setOpaque(false);
        jPanel2.setLayout(null);

        jTextField_Varenavn.setEditable(false);
        jTextField_Varenavn.setMinimumSize(new java.awt.Dimension(70, 25));
        jPanel2.add(jTextField_Varenavn);
        jTextField_Varenavn.setBounds(20, 20, 310, 30);

        jLabel1.setText("Varenavn");
        jLabel1.setPreferredSize(new java.awt.Dimension(50, 15));
        jPanel2.add(jLabel1);
        jLabel1.setBounds(20, 0, 160, 20);

        jTextField_Varenr.setEditable(false);
        jPanel2.add(jTextField_Varenr);
        jTextField_Varenr.setBounds(20, 70, 310, 30);

        jLabel4.setText("Varenummer");
        jLabel4.setPreferredSize(new java.awt.Dimension(50, 15));
        jPanel2.add(jLabel4);
        jLabel4.setBounds(20, 50, 90, 20);

        jTextField_Varegrp.setEditable(false);
        jPanel2.add(jTextField_Varegrp);
        jTextField_Varegrp.setBounds(20, 120, 310, 30);

        jLabel5.setText("Varegruppe");
        jLabel5.setPreferredSize(new java.awt.Dimension(60, 15));
        jPanel2.add(jLabel5);
        jLabel5.setBounds(20, 100, 150, 20);

        jLabel8.setText("Antal på lager");
        jPanel2.add(jLabel8);
        jLabel8.setBounds(20, 150, 130, 20);

        jTextField_Lager.setEditable(false);
        jTextField_Lager.setPreferredSize(new java.awt.Dimension(70, 25));
        jPanel2.add(jTextField_Lager);
        jTextField_Lager.setBounds(20, 170, 310, 30);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(20, 30, 350, 230);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        jPanel3.setOpaque(false);
        jPanel3.setLayout(null);

        jTextField_UdsalgsprisEUR.setEditable(false);
        jPanel3.add(jTextField_UdsalgsprisEUR);
        jTextField_UdsalgsprisEUR.setBounds(120, 90, 80, 30);

        jLabel6.setText("Udsalgspris DKK");
        jLabel6.setInheritsPopupMenu(false);
        jLabel6.setPreferredSize(new java.awt.Dimension(80, 15));
        jPanel3.add(jLabel6);
        jLabel6.setBounds(120, 10, 80, 20);

        jLabel7.setText("Udsalgspris EURO");
        jPanel3.add(jLabel7);
        jLabel7.setBounds(120, 70, 90, 20);

        jTextField_Rabat.setEditable(false);
        jPanel3.add(jTextField_Rabat);
        jTextField_Rabat.setBounds(20, 90, 70, 30);

        jLabel10.setText("Rabat");
        jPanel3.add(jLabel10);
        jLabel10.setBounds(20, 70, 70, 20);

        jTextField_Indkøbspris.setEditable(false);
        jPanel3.add(jTextField_Indkøbspris);
        jTextField_Indkøbspris.setBounds(20, 30, 70, 30);

        jLabel9.setText("Indkøbspris");
        jPanel3.add(jLabel9);
        jLabel9.setBounds(20, 10, 80, 20);

        jTextField_UdsalgsprisDKK.setEditable(false);
        jPanel3.add(jTextField_UdsalgsprisDKK);
        jTextField_UdsalgsprisDKK.setBounds(120, 30, 80, 30);

        jTextField_prisEUROmedRabat.setEditable(false);
        jPanel3.add(jTextField_prisEUROmedRabat);
        jTextField_prisEUROmedRabat.setBounds(230, 90, 80, 30);

        jTextField_PriDKKmedRabat.setEditable(false);
        jPanel3.add(jTextField_PriDKKmedRabat);
        jTextField_PriDKKmedRabat.setBounds(230, 30, 80, 30);

        jLabel15.setText("Pris i DKK med rabat");
        jPanel3.add(jLabel15);
        jLabel15.setBounds(230, 10, 110, 20);

        jLabel16.setText("Pris i EURO med rabat");
        jPanel3.add(jLabel16);
        jLabel16.setBounds(230, 70, 110, 20);

        getContentPane().add(jPanel3);
        jPanel3.setBounds(20, 280, 350, 150);

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/baggrund.png"))); // NOI18N
        getContentPane().add(jLabel18);
        jLabel18.setBounds(0, 0, 700, 440);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(VarePanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(VarePanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(VarePanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(VarePanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the dialog */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                VarePanel dialog = new VarePanel(new javax.swing.JFrame(), true, );
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//                    @Override
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField_Adresse;
    private javax.swing.JTextField jTextField_Indkøbspris;
    private javax.swing.JTextField jTextField_Kontaktperson;
    private javax.swing.JTextField jTextField_Lager;
    private javax.swing.JTextField jTextField_Leverandør;
    private javax.swing.JTextField jTextField_PriDKKmedRabat;
    private javax.swing.JTextField jTextField_Rabat;
    private javax.swing.JTextField jTextField_Tlf;
    private javax.swing.JTextField jTextField_UdsalgsprisDKK;
    private javax.swing.JTextField jTextField_UdsalgsprisEUR;
    private javax.swing.JTextField jTextField_Varegrp;
    private javax.swing.JTextField jTextField_Varenavn;
    private javax.swing.JTextField jTextField_Varenr;
    private javax.swing.JTextField jTextField_prisEUROmedRabat;
    // End of variables declaration//GEN-END:variables
}
